#include "processor.h"


void processor::trace_dispatch() {
	unsigned int i;
	unsigned int bundle_load, bundle_store;
	unsigned int index;
	bool load_flag;
	bool store_flag;
	bool A_ready;
	bool B_ready;
	db_t *actual;
	unsigned int oracle_address;

	int trace_width;

	// First stall condition: There isn't a dispatch bundle.
	if (!DISPATCH[0].valid)
		return;

	int current_index = DISPATCH[0].index;
	trace_width = PAY.buf[index].trace_length;
	// Second stall condition: There aren't enough AL entries for the dispatch bundle.
	// Check if the Dispatch Stage must stall due to either Active List not having sufficient entries for the dispatch bundle. (The current implementation keeps the two ALs redundant.)
	// * If either the integer Active List or floating-point Active List does not have enough entries for the *whole* dispatch bundle (which is always comprised of 'dispatch_width' instructions),
	//   then stall the Dispatch Stage. Stalling is achieved by returning from this function ('return').
	// * Else, don't stall the Dispatch Stage. This is achieved by doing nothing and proceeding to the next statements.
	//
	// Tips:
	// 1. If you need to stall, you do it by hard exiting this function with 'return'. Otherwise do nothing.

	if(REN_INT->stall_dispatch(trace_width) || REN_FP->stall_dispatch(trace_width));
	return;

	for (i = 0; i < dispatch_width; i++) {
		// Check LQ/SQ requirement.
		if (IS_LOAD(PAY.buf[index].flags))
		{
			bundle_load++;
		}
		else if (IS_STORE(PAY.buf[index].flags))
		{
			// Special cases:
			// S_S and S_D are split-stores, i.e., they are split into an addr-op and a value-op.
			// The two ops share a SQ entry to "rejoin". Therefore, only the first op should check
			// for and allocate a SQ entry; the second op should inherit the same entry.
			if (!PAY.buf[index].split_store || PAY.buf[index].upper)
				bundle_store++;
		}
	}

	if (LSU.stall(bundle_load, bundle_store))
		return;

	for(i=0; i<total_processing_elements; i++){
		if trace_processor[i].
	}
}
